import * as PIXI from 'pixi.js'
import icon from '@/utils/icon'
export default (textureSource: PIXI.TextureSource) => {
  const container = new PIXI.Container()
  const texture = new PIXI.Texture({
    source: textureSource,
    frame: new PIXI.Rectangle(1334, 1665, 309, 55),
  })

  const caseArr: Wx.Card.Optionobj[] = [
    {
      name: '系列',
      type: 'select',
      options: { all: ['全部系列', '开天系列', '御龙系列', '碎云系列', '补天系列', '灵犀系列', '仙缘系列', '兰因系列', '万象系列'] },
    },
    {
      name: '类别',
      type: 'select',
      options: {
        all: ['全部类别'],
        lives: ['散仙', '妖仙', '天仙'],
        magic: ['法术', '连锁法术', '触发法术'],
        equip: ['生灵装备', '主角装备'],
      },
    },
    {
      name: '模式',
      type: 'select',
      options: { all: ['全部卡牌', '快速模式专用', '标准模式专用'] },
    },
    {
      name: '搜索',
      type: 'input',
      icon: 'search',
      placeholder: '搜索',
    },
  ]
  caseArr.forEach((item, index) => {
    const caseContainer = new PIXI.Container()
    const sprite = new PIXI.Sprite(texture)
    sprite.anchor.set(0.5)
    caseContainer.addChild(sprite)
    let textContent = ''
    if (item.type === 'input') {
      if (item.icon) {
        const itemIcon = icon(item.icon)
        itemIcon.anchor.set(0, 0.5)
        itemIcon.scale.set(0.8)
        itemIcon.position.set(-72, 0)
        caseContainer.addChild(itemIcon)
      }
      textContent += item.placeholder || ''
    } else {
      textContent += item.options!.all![0]
    }
    // 文字显示
    const text = new PIXI.Text({
      text: textContent,
      style: {
        fontFamily: 'XQFont',
        fontSize: 36,
        fill: 0x000000,
        align: 'center',
      },
    })
    text.anchor.set(0.5)
    caseContainer.addChild(text)
    caseContainer.position.set(0, sprite.height * 1.3 * (index + 1))
    container.addChild(caseContainer)
  })
  return container
}
